package str

var index = make([]int, 0xffff)

func MaxLength(str string) int {
	//index := make(map[rune]int)
	//index := make([]int, 0xffff)
	for i := 0; i < len(index); i++ {
		index[i] = -1
	}
	maxLength := 0
	start := 0
	for i, ch := range []rune(str) {
		if lastI := index[ch]; lastI > start {
			start = lastI + 1
		}
		if i-start+1 > maxLength {
			maxLength = i - start + 1
		}
		index[ch] = i
	}
	return maxLength
}
